#ifndef QICONBUTTON_H
#define QICONBUTTON_H

#include <QWidget>
#include <QImage>
#include <QEvent>
enum eBtnStatus
{
    E_NORMAL = 100,
    E_FOCUSIN,
    E_PRESSED,
    E_FOCUSOUT,
    E_SELECTEDNOFOCUS,
};

enum eModel
{
    E_NORMALMODEL = 1000,
    E_THREESTATUSMODEL,
};

class QIconButton : public QWidget
{
    Q_OBJECT
public:
    explicit QIconButton(int nID, QString qsIconUrl, QSize size, QWidget *parent = nullptr);
    void addIcon(QString qsIconUrl);
    void setModel(eModel model);
    int  getId();
    bool hasSelected();
    void setSelected(bool bSelected);
    eBtnStatus getBtnStatus();
    void   setBtnStatus(eBtnStatus eStatus);
signals:
    void sigPressed(int);
protected:
    void enterEvent(QEnterEvent *event) override;
    void leaveEvent(QEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;
private:
    void paintEvent(QPaintEvent *event) override;
    QString         m_qsIconUrl;
    QImage          m_image;
    QImage          m_iamgeScale;
    int             m_nID;
    eBtnStatus      m_status;
    eModel          m_eModel;
    bool            m_bPressed;
    bool            m_bSelected;
};

#endif // QICONBUTTON_H
